// import home from '@/pages/home/home.vue'
// import login from '@/pages/login/login.vue'
// import register from '@/pages/register/register.vue'
// import search from '@/pages/search'
// import detail from '@/pages/detail'
// import AddCartSuccess from '@/pages/AddCartSuccess'
// import ShopCart from '@/pages/ShopCart'
// import Trade from '@/pages/Trade'
// import Pay from '@/pages/Pay'
// import PaySuccess from '@/pages/PaySuccess'
// import Center from '@/pages/Center'
// import myOrder from '@/pages/Center/myOrder'
// import teamorder from '@/pages/Center/teamorder'

export const routes = [
    //默认页
    {
        path: '/home',
        component: () => import('@/pages/home/home.vue'),
        //路由元信息
        meta: {
            show: true
        }
    },
    //搜索页
    {
        path: '/search/:title?',//params传参,配置为可选参数,因为用户可能不输入内容直接搜索
        // params传参必须用name
        name: 'search',
        component: () => import('@/pages/search'),
        // 获取传参内容
        props: router => {
            return ({ ...router.params, ...router.query })
        },
        meta: {
            show: true
        }
    },
    //登录页
    {
        path: '/login',
        component: () => import('@/pages/login/login.vue'),
        meta: {
            show: false
        }
    },
    //注册
    {
        path: '/register',
        component: () => import('@/pages/register/register.vue'),
        meta: {
            show: false
        }
    },
    // 商品详情页
    {
        name: 'detail',
        // 占位加冒号!!!
        path: '/detail/:skyId?',
        component: () => import('@/pages/detail'),
        meta: {
            show: true
        }
    },
    // 添加购物车
    {
        name: 'AddCartSuccess',
        path: '/AddCartSuccess/:skyNum',
        component: () => import('@/pages/AddCartSuccess'),
        meta: {
            show: true
        }
    },
    // 购物车结算
    {
        path: '/shopcart',
        component: () => import('@/pages/ShopCart'),
        meta: {
            show: true
        }
    },
    // 购物车结算页
    {
        path: '/trade',
        component: () => import('@/pages/Trade'),
        meta: {
            show: true
        },
        // 路由独享守卫
        beforeEnter: (to, from, next) => {
            // 只能从shopcart 跳转过来,否则就停留在原地
            if (from.path == '/shopcart') {
                next()
            } else {
                next(false)
            }
        }
    },
    // pay 支付页
    {
        path: '/pay',
        component: () => import('@/pages/Pay'),
        meta: {
            show: true
        }
    },
    //支付成功页面
    {
        path: '/paysuccess',
        component: () => import('@/pages/PaySuccess'),
        meta: {
            show: true
        }
    },
    //我的订单
    {
        path: '/center',
        component: () => import('@/pages/Center'),
        meta: {
            show: true
        },
        children: [
            // 我的订单
            {
                path: '/center/myOrder',
                component: () => import('@/pages/Center/myOrder'),
            },
            //团购订单
            {
                path: 'teamorder',
                component: () => import('@/pages/Center/teamorder'),
            },
            // 默认路由
            {
                path: '/center',
                redirect: 'myOrder'
            }
        ]
    },
    // 重定向
    {
        // 重定向:当访问/ 重定向/home
        path: '/',
        redirect: '/home'
    }
]